load(
    "//bazel:tachyon_cc.bzl",
    "tachyon_cc_library",
    "tachyon_cc_unittest",
    "tachyon_openmp_num_threads_env",
)

package(default_visibility = ["//visibility:public"])

COMMON_TEST_DATA_DEPS = [
    ":circuit_test_data",
    ":circuit_test_type_traits",
    ":point",
]

COMMON_TEST_DEPS = [
    ":circuit_test",
    "//tachyon/zk/plonk/layout/floor_planner:simple_floor_planner",
    "//tachyon/zk/plonk/layout/floor_planner/v1:v1_floor_planner",
]

tachyon_cc_library(
    name = "circuit_test_data",
    testonly = True,
    hdrs = ["circuit_test_data.h"],
    deps = [
        ":point",
        "//tachyon/base:range",
    ],
)

tachyon_cc_library(
    name = "circuit_test_type_traits",
    testonly = True,
    hdrs = ["circuit_test_type_traits.h"],
    deps = [
        "//tachyon/math/elliptic_curves/bn/bn254",
        "//tachyon/zk/base/commitments:gwc_extension",
        "//tachyon/zk/base/commitments:shplonk_extension",
        "//tachyon/zk/plonk/examples/fibonacci:fibonacci1_circuit",
        "//tachyon/zk/plonk/examples/fibonacci:fibonacci2_circuit",
        "//tachyon/zk/plonk/examples/fibonacci:fibonacci3_circuit",
        "//tachyon/zk/plonk/halo2:prover_test",
        "//tachyon/zk/plonk/halo2:proving_scheme",
        "//tachyon/zk/plonk/layout/floor_planner:simple_floor_planner",
        "//tachyon/zk/plonk/layout/floor_planner/v1:v1_floor_planner",
    ],
)

tachyon_cc_library(
    name = "circuit_test",
    testonly = True,
    hdrs = ["circuit_test.h"],
    deps = [
        ":point",
        "//tachyon/base/containers:container_util",
        "//tachyon/math/elliptic_curves/bn/bn254",
        "//tachyon/math/elliptic_curves/bn/bn254/halo2:bn254",
        "//tachyon/zk/lookup:pair",
        "//tachyon/zk/plonk/halo2:pinned_constraint_system",
        "//tachyon/zk/plonk/halo2:pinned_verifying_key",
        "//tachyon/zk/plonk/halo2:prover_test",
        "//tachyon/zk/plonk/keys:proving_key",
        "//tachyon/zk/plonk/layout/floor_planner:simple_floor_planner",
        "//tachyon/zk/plonk/layout/floor_planner/v1:v1_floor_planner",
    ],
)

tachyon_cc_library(
    name = "point",
    hdrs = ["point.h"],
)

tachyon_cc_library(
    name = "multi_lookup_circuit",
    hdrs = ["multi_lookup_circuit.h"],
    deps = ["//tachyon/zk/plonk/constraint_system:circuit"],
)

tachyon_cc_library(
    name = "multi_lookup_circuit_test_data",
    testonly = True,
    hdrs = ["multi_lookup_circuit_test_data.h"],
    deps = COMMON_TEST_DATA_DEPS,
)

tachyon_cc_library(
    name = "shuffle_circuit",
    hdrs = ["shuffle_circuit.h"],
    deps = [
        "//tachyon/zk/plonk/constraint_system:circuit",
        "@com_google_absl//absl/strings",
    ],
)

tachyon_cc_library(
    name = "shuffle_circuit_test_data",
    testonly = True,
    hdrs = ["shuffle_circuit_test_data.h"],
    deps = COMMON_TEST_DATA_DEPS,
)

tachyon_cc_library(
    name = "shuffle_api_circuit",
    hdrs = ["shuffle_api_circuit.h"],
    deps = [
        "//tachyon/zk/plonk/constraint_system:circuit",
        "@com_google_absl//absl/strings",
    ],
)

tachyon_cc_library(
    name = "shuffle_api_circuit_test_data",
    testonly = True,
    hdrs = ["shuffle_api_circuit_test_data.h"],
    deps = COMMON_TEST_DATA_DEPS,
)

tachyon_cc_library(
    name = "simple_circuit",
    hdrs = ["simple_circuit.h"],
    deps = ["//tachyon/zk/plonk/constraint_system:circuit"],
)

tachyon_cc_library(
    name = "simple_circuit_test_data",
    testonly = True,
    hdrs = ["simple_circuit_test_data.h"],
    deps = COMMON_TEST_DATA_DEPS,
)

tachyon_cc_library(
    name = "simple_lookup_circuit",
    hdrs = ["simple_lookup_circuit.h"],
    deps = ["//tachyon/zk/plonk/constraint_system:circuit"],
)

tachyon_cc_library(
    name = "simple_lookup_circuit_test_data",
    testonly = True,
    hdrs = ["simple_lookup_circuit_test_data.h"],
    deps = COMMON_TEST_DATA_DEPS + ["//tachyon/base:range"],
)

tachyon_cc_unittest(
    name = "multi_lookup_circuit_test",
    srcs = ["multi_lookup_circuit_test.cc"],
    env = tachyon_openmp_num_threads_env(4),
    tags = ["gpu_heavy_test"],
    deps = COMMON_TEST_DEPS + [
        ":multi_lookup_circuit",
        ":multi_lookup_circuit_test_data",
    ],
)

tachyon_cc_unittest(
    name = "shuffle_circuit_test",
    srcs = ["shuffle_circuit_test.cc"],
    env = tachyon_openmp_num_threads_env(4),
    tags = ["gpu_heavy_test"],
    deps = COMMON_TEST_DEPS + [
        ":shuffle_circuit",
        ":shuffle_circuit_test_data",
    ],
)

tachyon_cc_unittest(
    name = "shuffle_api_circuit_test",
    srcs = ["shuffle_api_circuit_test.cc"],
    env = tachyon_openmp_num_threads_env(4),
    tags = ["gpu_heavy_test"],
    deps = COMMON_TEST_DEPS + [
        ":shuffle_api_circuit",
        ":shuffle_api_circuit_test_data",
    ],
)

tachyon_cc_unittest(
    name = "simple_circuit_test",
    srcs = ["simple_circuit_test.cc"],
    env = tachyon_openmp_num_threads_env(4),
    tags = ["gpu_heavy_test"],
    deps = COMMON_TEST_DEPS + [
        ":simple_circuit",
        ":simple_circuit_test_data",
    ],
)

tachyon_cc_unittest(
    name = "simple_lookup_circuit_test",
    srcs = ["simple_lookup_circuit_test.cc"],
    env = tachyon_openmp_num_threads_env(4),
    tags = ["gpu_heavy_test"],
    deps = COMMON_TEST_DEPS + [
        ":simple_lookup_circuit",
        ":simple_lookup_circuit_test_data",
    ],
)
